<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="axios.min.js"></script>
</head>
<body>
<h3>表单提交 ( GET 方式 )</h3>
<form action="http://127.0.0.1:8080/post.do" style="text-align: right; width: 300px;">
账号:<input name="name" style="width: 250px; box-sizing: border-box;"><br>
密码:<input name="pwd" type="text" style="width: 250px; box-sizing: border-box;"><br>
<button>登录</button>
</form> <h3>表单提交 ( POST 方式 )</h3>
<form action="http://127.0.0.1:8080/post.do" method="post" style="text-align: right; width: 300px;">
    账号:<input name="name" style="width: 250px; box-sizing: border-box;"><br>
    密码:<input name="pwd" type="password" style="width: 250px; box-sizing: border-box;"><br>
    <button>登录</button>
</form>
<h3>表单提交 ( 文件提交方式 )</h3>
<form action="http://127.0.0.1:8080/post.do" method="post"
      enctype="multipart/form-data">
    账号:<input name="name" style="width: 250px; box-sizing: border-box;">
    <br>  文件:<input name="file" type="file" /><br>
    <button>提交</button>
</form>
<hr>
<button onclick="get()">axios get</button>
<button onclick="post()">axios post</button>
<button onclick="upfile()">axios file upload</button>

<script >
   function get(){
       axios.get("http://127.0.0.1:8080/404.do",{
           params:{
               name:"zhangsan",
               age:"18",
           }
       })
   }
    function post(){
       let params = new URLSearchParams();
       params.append("name","zhangsan")
        params.append("age","18")
        axios.post("http://127.0.0.1:8080/404.do",params);
    }
    function upfile() {
       let params = new FormData();
       params.append("name","zhangsan");
       params.append("age","18");
       params.append("file",myfile.files[0])
        axios.post("http://127.0.0.1:8080/404.do",params)
    }
</script>
</body>
</html>